/*
    REDLisp - interpreter/compiler for new dialect of LISP called REDLISP
    Copyright (C) 2006  Rudolf Olah

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef PARSER_H
#define PARSER_H

#include "core.h"
#include "types.h"
#include "functions.h"
#include <string>
#include <iostream>
#include <stdio.h>

extern dSymbol *T;
extern dList *nil;

// Parses a string by tokenizing it and passing it to the other parse
// function
dList *parse (string line);
// Parses a list of strings (input comes from tokenize function usually)
dList *parse (dList *line);

// Parses and evaluates an expression in the form of a string
dObject *eval (string exp, dList *environment=0, dList *env2=0);
// Evaluates an already-parsed expression in the form of a list
dObject *eval (dList *expList, dList *environment=0, dList *env2=0);

// Both methods add a variable/value pair to an environment dList
// example of an environment list: ((variable value) (variable value))
dObject *add_variable (string key, dObject *data, dList *environment=0);
dObject *add_variable (dSymbol *key, dObject *data, dList *environment=0);

// Returns the value of a variable. Searches env1 first then env2
// ToDo: Make it look through a list of environments (variable scope)
dObject *get_variable (dSymbol *var, dList *env1=0, dList *env2=0);

// Removes a variable/value pair from an environment dList
dObject *delete_variable (dSymbol *var, dList *environment=0);

// Gets the value of item, or evalutes it and then tries to get the
// value if possible
dObject *process (dObject *item, dList *env1=0, dList *env2=0);

#endif
